//package com.kingjw.sql
//
//import org.apache.spark.SparkConf
//import org.apache.spark.rdd.RDD
//import org.apache.spark.sql.expressions.Aggregator
//import org.apache.spark.sql.{DataFrame, Dataset, Row, SaveMode, SparkSession}
//
///**
// *
// * @Package: com.kingjw.sql
// * @ClassName: UDAFZDY
// * @Author: 王坚伟
// * @CreateTime: 2021/11/11 15:11
// * @Description:
// */
//object SqlTest2 {
//  def main(args: Array[String]): Unit = {
//    System.setProperty("HADOOP_USER_NAME", "kingjw")
//    val conf: SparkConf = new SparkConf().setMaster("local[*]").setAppName("SparkSQL")
//    conf.set("spark.sql.warehouse.dir", "hdfs://hadoop117:8020/user/hive/warehouse")
//    val spark: SparkSession = SparkSession
//      .builder()
//      .enableHiveSupport()
//      .config(conf)
//      .getOrCreate()
//
////    spark.sql("show tables").show()
//    //指定数据库
//    spark.sql("use atguigu")
//
//
//    val frame: DataFrame = spark.sql(
//      """
//        |CREATE TABLE `user_visit_action`(
//        |    `date` string,
//        |    `user_id` bigint,
//        |    `session_id` string,
//        |    `page_id` bigint,
//        |    `action_time` string,
//        |    `search_keyword` string,
//        |    `click_category_id` bigint,
//        |    `click_product_id` bigint,
//        |    `order_category_ids` string,
//        |    `order_product_ids` string,
//        |    `pay_category_ids` string,
//        |    `pay_product_ids` string,
//        |    `city_id` bigint)
//        |row format delimited fields terminated by '\t';
//        |""".stripMargin)
//    val value: Dataset[Row] = frame
//      .repartition(10)
//    spark.sql("load data local inpath 'input/user_visit_action.txt' into table user_visit_action;")
//    spark.sql(
//      """
//        |CREATE TABLE `city_info`(
//        |    `city_id` bigint,
//        |    `city_name` string,
//        |    `area` string)
//        |row format delimited fields terminated by '\t';
//        |""".stripMargin)
//    spark.sql("load data local inpath 'input/city_info.txt' into table city_info;")
//
//
//    spark.close()
//  }
//
//}
//
